﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using BE;

namespace WCF
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : BL_Server.IBL
    {
        BL_Server.IBL bl;

        public Service1()
        {
            bl = new BL_Server.BL();
        }

        #region Cities
        public List<BE.Model.City> GetAllCities()
        {
            return bl.GetAllCities().ToList();
        }

        public bool AddCity(BE.Model.City city)
        {
            return bl.AddCity(city);
        }

        public bool RemoveCity(int ID)
        {
            return bl.RemoveCity(ID);
        }

        public bool UpdateCity(BE.Model.City city)
        {
            return bl.UpdateCity(city);
        }
        #endregion

        #region Professions
        public List<BE.Model.Profession> GetAllProfessions()
        {
            return bl.GetAllProfessions().ToList();
        }

        public bool AddProfession(BE.Model.Profession profession)
        {
            return bl.AddProfession(profession);
        }

        public bool RemoveProfession(int ID)
        {
            return bl.RemoveProfession(ID);
        }

        public bool UpdateProfession(BE.Model.Profession profession)
        {
            return bl.UpdateProfession(profession);
        }
        #endregion

        #region Programs
        public List<BE.Model.Program> GetAllPrograms()
        {
            return bl.GetAllPrograms();
        }

        public bool AddProgram(BE.Model.Program program)
        {
            return bl.AddProgram(program);
        }

        public bool RemoveProgram(int id)
        {
            return bl.RemoveProgram(id);
        }

        public bool UpdateProgram(BE.Model.Program program)
        {
            return bl.UpdateProgram(program);
        }
        #endregion

        #region Dorms
        public List<BE.Model.Dorm> GetAllDorms()
        {
            return bl.GetAllDorms().ToList();
        }

        public bool AddDorm(BE.Model.Dorm dorm)
        {
            return bl.AddDorm(dorm);
        }

        public bool RemoveDorm(int ID)
        {
            return bl.RemoveDorm(ID);
        }

        public bool UpdateDorm(BE.Model.Dorm dorm)
        {
            return bl.UpdateDorm(dorm);
        }
        #endregion

        #region Rooms
        public List<BE.Model.Room> GetAllRooms()
        {
            return bl.GetAllRooms().Select(r => BE.WCFHelper.TransferRoom(r)).ToList();
        }

        public bool AddRoom(BE.Model.Room room)
        {
            return bl.AddRoom(room);
        }

        public bool RemoveRoom(int id)
        {
            return bl.RemoveRoom(id);
        }

        public bool UpdateRoom(BE.Model.Room room)
        {
            return bl.UpdateRoom(room);
        }
        #endregion

        #region Charges
        public IEnumerable<BE.Model.Charge> GetAllCharges()
        {
            return bl.GetAllCharges().ToList();
        }

        public bool AddCharge(BE.Model.Charge charge)
        {
            return bl.AddCharge(charge);
        }

        public bool RemoveCharge(int id)
        {
            return bl.RemoveCharge(id);
        }

        public bool UpdateCharge(BE.Model.Charge charge)
        {
            return bl.UpdateCharge(charge);
        }
        #endregion

        #region Students
        public IEnumerable<BE.Model.Student> GetAllStudents()
        {
            return bl.GetAllStudents().Select(r => BE.WCFHelper.TransferStudent(r)).ToList();
        }

        public bool AddStudent(BE.Model.Student student)
        {
            return bl.AddStudent(student);
        }

        public bool RemoveStudent(int id)
        {
            return bl.RemoveStudent(id);
        }

        public bool UpdateStudent(BE.Model.Student student)
        {
            return bl.UpdateStudent(student);
        }
        #endregion

        #region Placements
        public IEnumerable<BE.Model.Placement> GetAllPlacements()
        {
            return bl.GetAllPlacements().Select(r => BE.WCFHelper.TransferPlacement(r)).ToList();
        }

        public bool AddPlacement(BE.Model.Placement placement)
        {
            return bl.AddPlacement(placement);
        }

        public bool RemovePlacement(int id)
        {
            return bl.RemovePlacement(id);
        }

        public bool UpdatePlacement(BE.Model.Placement placement)
        {
            return bl.UpdatePlacement(placement);
        }
        #endregion

        #region Users
        public IEnumerable<BE.Model.User> GetAllUsers()
        {
            return bl.GetAllUsers();
        }

        public bool AddUser(BE.Model.User user)
        {
            return bl.AddUser(user);
        }

        public bool RemoveUser(int id)
        {
            return bl.RemoveUser(id);
        }

        public bool UpdateUser(BE.Model.User user)
        {
            return bl.UpdateUser(user);
        }

        public BE.Model.User GetUserByID(int id)
        {
            return bl.GetUserByID(id);
        }

        public BE.Model.User GetUserByEmail(string email)
        {
            return bl.GetUserByEmail(email);
        }
        #endregion
    }
}
